//
//  WYUserView.m
//  WisdomCommunity
//
//  Created by Yahaong on 16/7/28.
//  Copyright © 2016年 zonten. All rights reserved.
//

#import "WYUserView.h"
#import "UIButton+ButtonStyle.h"
#import "YHMarcros.h"

@interface WYUserView ()
@property(nonatomic, strong)UIImageView *bgImageView;
@property(nonatomic, strong)UIButton *locationButton;
@property(nonatomic, strong)UILabel *titleLbabel;
@property(nonatomic, strong)UILabel *nameLabel;
@end
@implementation WYUserView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    [self addSubview:self.bgImageView];
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [self addSubview:self.titleLbabel];
    [self.titleLbabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top);
        make.leading.equalTo(self).offset(20);
        make.height.equalTo(self).multipliedBy(0.5);
    }];
    [self addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLbabel.bottom);
        make.leading.equalTo(self.titleLbabel);
        make.height.equalTo(self.titleLbabel);
    }];
    
    [self addSubview:self.locationButton];
    [self.locationButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.trailing.equalTo(self).offset(-10);
        
    }];

}
- (void)layoutSubviews{
    [super layoutSubviews];
    [self.locationButton layoutButtonWithEdgeInsetsStyle:ButtonEdgeInsetsStyleTop imageTitleSpace:0];

}
- (UIImageView *)bgImageView
{
    if (!_bgImageView) {
        _bgImageView = [[UIImageView alloc]init];
        _bgImageView.image = [UIImage imageNamed:@"property_icon_bg"];
    }
    return _bgImageView;
}

- (UIButton *)locationButton
{
    if (!_locationButton) {
        _locationButton = [[UIButton alloc]init];
        [_locationButton setImage:[UIImage imageNamed:@"property_icon_location"] forState:UIControlStateNormal];
        [_locationButton setTitle:@"成都" forState:UIControlStateNormal];
    }
    return _locationButton;
}

- (UILabel *)titleLbabel
{
    if (!_titleLbabel) {
        _titleLbabel = [[UILabel alloc]init];
        _titleLbabel.text = @"蔚蓝卡地亚(二栋一单元 0201 室)";
        _titleLbabel.textColor = [UIColor whiteColor];

    }
    return _titleLbabel;
}
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.text = @"王老师  156****2673)";
        _nameLabel.textColor = [UIColor whiteColor];
    }
    return _nameLabel;
}

@end
